package com.doit.spark.day04

import com.doit.spark.day01.utils.SparkUtil
import org.apache.spark.CheckPointLoader
import org.apache.spark.rdd.RDD

/**
 * @DATE 2022/1/6/17:53
 * @Author MDK
 * @Version 2021.2.2
 * */
object C04_CheckPoint02 {
  def main(args: Array[String]): Unit = {
    val sc = SparkUtil.getSc
    //将存储的rdd5(Int, Int)中的数据  加载出来
    //重写加载程序的方法  loader
    /* 源码示例
    *  SparkContext 类中
    *  ----加载checkpoint的数据
    *  protected[spark] def checkpointFile[T: ClassTag](path: String): RDD[T] = withScope {
    *  new ReliableCheckpointRDD[T](this, path)
    *  }
    * */
    val rdd: RDD[(Int, Int)] = CheckPointLoader.load(sc, "data/checkpoint/rdd5/1f91ea6d-7674-4ae9-9c52-b6cd7907576c/rdd-4")
    rdd.foreach(println)
  }
}
